package com.wmx.service.impl;

import com.wmx.repository.TVRepository;
import com.wmx.service.TVServiceExt;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * 电视业务层接口实现
 *
 * @author wangMaoXiong
 * @version 1.0
 * @date 2022/4/9 8:33
 */
@Service
public class TVServiceExtImpl implements TVServiceExt {

    @Resource
    private TVRepository tvRepository;

    /**
     * REQUIRES_NEW：表示新开一个事务，如果当前已经有事务，则会暂停
     *
     * @param id
     */
    @Override
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
    public void deleteByIdExt(int id) {
        boolean existsById = tvRepository.existsById(id);
        if (existsById){
            tvRepository.deleteById(id);
        }
        // System.out.println("123".split(",")[1]);
    }

}
